import Camera from "./Camera";
import Model from "./Model";
import Renderer from "./Renderer";


class Director {
    models: Model[] = [];
    camera: Camera;
    constructor() {
    }

    initCamera() {
        if (!this.camera) {
            this.camera = new Camera();
        }
        Renderer.instance.setCamera(this.camera);
    }

    loadScene(models: Model[]) {
        let gl = Renderer.instance.gl;
        this.models = models;
        this.initCamera();
        this.mainLoop();
        gl.enable(gl.DEPTH_TEST);
        gl.enable(gl.BLEND);
        gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
    }


    mainLoop() {
        // SingletonMgr.getInst(Renderer).render(this._scene);
        Renderer.instance.render(director.models);
        requestAnimationFrame(director.mainLoop);
    }
}
let director = new Director()
window['director'] = director;
export default director;
